from langchain_community.document_loaders import WikipediaLoader
from langchain.text_splitter import TokenTextSplitter


def get_split_doc(query):

    raw_documents = WikipediaLoader(query=query, load_max_docs=1).load()
    text_splitter = TokenTextSplitter(chunk_size=512, chunk_overlap=24)
    documents = text_splitter.split_documents(raw_documents[:3])
    print("Load and Split document successfully.")
    return documents


if __name__ == "__main__":

    print(len(get_split_doc("Elizabeth I")))
